/*
 * Created by Jaren at 2021/12/27 10:59
 */
import 'dart:typed_data';

import 'package:binary/binary.dart';
import 'package:inmotion_protocol/util/byte_util.dart';

class LightEffectMode {
    Uint8 mode = Uint8.zero;
    Uint8 p1 = Uint8.zero;
    Uint8 p2 = Uint8.zero;
    Uint8 p3 = Uint8.zero;
    Uint8 p4 = Uint8.zero;

    LightEffectMode.fromBytes(Uint8ClampedList bytes, [int offset = 0]){
        mode = ByteUtil.toUint8(bytes[0]);
        p1 = ByteUtil.toUint8(bytes[1]);
        p2 = ByteUtil.toUint8(bytes[2]);
        p3 = ByteUtil.toUint8(bytes[3]);
        p4 = ByteUtil.toUint8(bytes[4]);
    }

    Uint32 colorOfModeByMusic() {
        return Uint32((p1.value << 16) | (p2.value << 8) | p3.value);
    }

    Uint8 styleOfModeBySpeed() {
        return p1;
    }
}